package org.saratogaschools.edd.firefighter.client.view;

import java.util.List;

import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.cellview.client.CellList;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class ManageFireView extends Composite {
	
	public interface Presenter {

		void extinguish();

		void back();
		
	}
	
	private Presenter presenter;
	
	@UiField(provided=true)
	CellList<String> nameList;

	private static ManageFireViewUiBinder uiBinder = GWT
			.create(ManageFireViewUiBinder.class);

	interface ManageFireViewUiBinder extends UiBinder<Widget, ManageFireView> {
	}

	public ManageFireView() {
		this.nameList = new CellList<String>(new TextCell());
		initWidget(uiBinder.createAndBindUi(this));
	}
	
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
	}
	
	@UiHandler("extinguishButton")
	void onExtinguishClicked(ClickEvent evt) {
		presenter.extinguish();
	}
	
	@UiHandler("backButton")
	void onBackButtonClicked(ClickEvent evt) {
		presenter.back();
	}
	
	public void setNames(List<String> names) {
		nameList.setRowCount(names.size(), true);
		nameList.setRowData(names);
	}

}
